package com.ytf.test.seventh;

class Poppet{
    private int i;

    public Poppet(int i) {
        this.i = i;
    }

    @Override
    public String toString() {
        return "Poppet{" +
                "i=" + i +
                '}';
    }
}
/**
 * @author: YTF
 * @date: 2024/12/4 15:16
 * @version: 1.0
 * @description:
 */
public class BlankFinal {
    private final int i = 0; // Initialized final
    private final int j; // Blank final
    private final Poppet p; // Blank final reference

    public BlankFinal() {
        this.j = 1;
        this.p = new Poppet(1);
    }

    public BlankFinal(int j) {
        this.j = j;
        this.p = new Poppet(j);
    }

    @Override
    public String toString() {
        return "BlankFinal{" +
                "i=" + i +
                ", j=" + j +
                ", p=" + p +
                '}';
    }

    public static void main(String[] args) {
        System.out.println(new BlankFinal().toString());
        System.out.println(new BlankFinal(47).toString());
        /**
         * Output:
         * BlankFinal{i=0, j=1, p=Poppet{i=1}}
         * BlankFinal{i=0, j=47, p=Poppet{i=47}}
         *
         * 总结:
         * final 允许空白final但编译使用前必须初始化
         */
    }
}
